﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WorkOrder.Models;

/// <summary>
/// 工单分派记录表
/// </summary>
[Table("工单分派记录表")]
[Index("工单id", Name = "fk_分派_工单")]
[Index("开始时间", "结束时间", Name = "idx_分派时间")]
[Index("是否当前负责人", Name = "idx_当前负责人")]
[Index("用户id", Name = "idx_用户")]
public partial class 工单分派记录表
{
    /// <summary>
    /// 分派ID
    /// </summary>
    [Key]
    [Column("分派ID")]
    public long 分派id { get; set; }

    /// <summary>
    /// 工单ID
    /// </summary>
    [Column("工单ID")]
    public string 工单id { get; set; }

    /// <summary>
    /// 负责人
    /// </summary>
    [Column("用户ID")]
    public string 用户id { get; set; }

    /// <summary>
    /// 分派类型
    /// </summary>
    public AssignmentType 分派类型 { get; set; }= AssignmentType.主要; // 直接使用枚举类型

    /// <summary>
    /// 开始时间
    /// </summary>
    [Column(TypeName = "datetime")]
    public DateTime 开始时间 { get; set; }

    /// <summary>
    /// 结束时间
    /// </summary>
    [Column(TypeName = "datetime")]
    public DateTime? 结束时间 { get; set; }

    /// <summary>
    /// 是否当前负责人
    /// </summary>
    [Required]
    public bool? 是否当前负责人 { get; set; }

    /// <summary>
    /// 分派说明
    /// </summary>
    [Column(TypeName = "text")]
    public string? 分派说明 { get; set; }

    /// <summary>
    /// 分派操作人
    /// </summary>
    [Column("分派操作人")]
    public string? 分派操作人 { get; set; }

    /// <summary>
    /// 分派批次ID
    /// </summary>
    [Column("分派批次ID")]
    public string 分派批次id { get; set;}

    [ForeignKey("工单id")]
    [InverseProperty("工单分派记录表s")]
    public virtual 工单主表 工单 { get; set; } = null!;
}
